import { _decorator, assetManager, Canvas, Component, debug, director, find, log, macro, Node, Tween, tween, Vec3, View, view } from 'cc';
import { weixinapi } from './weixinAIP';
import { UIManager } from 'db://assets/3rd/Guyu/Scripts/[框架]/通用UI/UIManager';
import TaskResMgr from 'db://assets/3rd/Guyu/Scripts/[业务]/广告任务/Model/TaskResMgr';
import TaskWeb from '../../../3rd/Guyu/Scripts/[业务]/广告任务/Controller/TaskWeb';



const { ccclass, property } = _decorator;

@ccclass('TSjiazaichangjing')
export class TSjiazaichangjing extends Component {
    //通用缓存
    HC_yinxiaokongzhi = true
    HC_yinyuekongzhi = true
    HC_zhengdongkongzhi = true
    HC_qiandao_riqi = -1

    HC_wuxian_riqi = -1
    //
    HC_tilizhi = 5
    HC_XLMJ_zuigaofen = 0
    HC_qian = 200
    HC_doudongshu = 5
    HC_ZGguang = 0
    HC_wuxiantili = false
    HC_JYFK_CCYX = true
    HC_XGQ_chuangguangshu = 0
    HC_MLGM_chuangguangshu = 0

    HC_chuci_XLMJ = true
    //模式解锁
    HC_JS_MLGM = false          //麻了个嘛
    HC_JS_MJXGQ = false            //麻将消个球
    HC_JS_JYMJ = false           //解压麻将
    HC_JS_XLMJ = false       //下落麻将

    //体验次数


    async start() {
        
        weixinapi.k开启分享()
        // weixinapi.c初始加载激励广告()
        // weixinapi.c创建插屏广告()
        TaskWeb.getTaskConfig();


        macro.ENABLE_MULTI_TOUCH = false      //禁止多指操作，系统默认为true，更改后切换场景也不会改变，一次设置所有后续都为该量
        console.log('开启禁止多指操作')
        this.c记录缓存()

        let n2 = find('Canvas/遮罩_进度条/进度条')
        tween(n2).to(10, { position: new Vec3(-100, 0, 0) }).start()
        //预加载场景
        let f = () => {
            Tween.stopAllByTarget(n2); n2.setPosition(0, 0, 0)
            director.loadScene('kaishichangjing')
        }
        let m = 'kaishichangjing'
        assetManager.loadBundle('fb', (err, a) => { a.loadScene(m, f); });
        // this.c记录缓存()
    }

    c记录缓存() {
        //判断用户数据不存在则存储为用户初始数据
        function jilu(lab: string, n) {
            let a = localStorage.getItem(lab)
            if (a == null || a == '') { localStorage.setItem(lab, JSON.stringify(n)); }
            console.log(lab + ':' + localStorage.getItem(lab))
        }
        //  jilu('', this.)

        jilu('HC_yinxiaokongzhi', this.HC_yinxiaokongzhi)
        jilu('HC_yinyuekongzhi', this.HC_yinyuekongzhi)
        jilu('HC_zhengdongkongzhi', this.HC_zhengdongkongzhi)
        jilu('HC_qiandao_riqi', this.HC_qiandao_riqi)
        jilu('HC_wuxian_riqi', this.HC_wuxian_riqi)


        jilu('HC_XLMJ_zuigaofen', this.HC_XLMJ_zuigaofen)
        jilu('HC_tilizhi', this.HC_tilizhi)
        jilu('HC_qian', this.HC_qian)
        jilu('HC_doudongshu', this.HC_doudongshu)
        jilu('HC_ZGguang', this.HC_ZGguang)
        jilu('HC_wuxiantili', this.HC_wuxiantili)
        jilu('HC_JYFK_CCYX', this.HC_JYFK_CCYX)
        jilu('HC_XGQ_chuangguangshu', this.HC_XGQ_chuangguangshu)
        jilu('HC_MLGM_chuangguangshu', this.HC_MLGM_chuangguangshu)

        jilu('HC_JS_MLGM', this.HC_JS_MLGM)
        jilu('HC_JS_MJXGQ', this.HC_JS_MJXGQ)
        jilu('HC_JS_JYMJ', this.HC_JS_JYMJ)
        jilu('HC_JS_XLMJ', this.HC_JS_XLMJ)

        jilu(' HC_chuci_XLMJ', this.HC_chuci_XLMJ)

    }

}


